package com.bite.ioc.controller;

import com.bite.ioc.model.UserInfo;
import com.bite.ioc.service.UserService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {
    //属性注入
//    @Autowired
//    private UserService userService;

 //构造方法注入
//    private UserService userService;
//
//    private UserInfo userInfo;
//
//    public UserController() {
//        System.out.println("无参构造方法");
//    }
//
//    @Autowired
//    public UserController(UserService userService, UserInfo userInfo) {
//        System.out.println("有参构造方法");
//        this.userInfo = userInfo;
//        this.userService = userService;
//    }

    //setter方法注入
    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void say(){
        System.out.println("UserController say...");
        userService.say();
//        System.out.println(userInfo);
    }
}
